/**
 * 
 */
package com.teach.servlet.admin;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.teach.service.UserDeleteService;
import com.teach.service.UserDisplayService;
import com.teach.service.impl.UserDeleteServiceImpl;
import com.teach.service.impl.UserDisplayServiceImpl;

/**
 * @author Liulianqiu
 *2020年7月29日
 */
public class UserDeleteServlet extends HttpServlet {
	
	private UserDeleteService userDeleteService = new UserDeleteServiceImpl();
	private UserDisplayService userDisplayService = new UserDisplayServiceImpl();

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		try {
			//获取请求参数
			//调用业务逻辑层接口
			request.setAttribute("list", userDisplayService.list(0,Integer.valueOf(request.getParameter("num"))));
			userDeleteService.delete(Integer.valueOf(request.getParameter("userId")));
			request.setAttribute("msg", "删除用户成功");
			request.setAttribute("href", "admin/display-user.let");
		} catch (Exception e) {
			e.printStackTrace();//记调试日志
			request.setAttribute("error", "删除用户失败"+e.getMessage());
		}
		//跳转视图
		request.getRequestDispatcher("/admin/msg.jsp").forward(request, response);
	}
	

}
